package cn.itcast.usercontext.interceptor;


import cn.itcast.usercontext.util.usersession.LoginUser;
import org.example.userclient.UserClient;
import org.example.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author sxt
 * @version 1.0
 * @description TODO
 * @date 2024/4/25 15:51
 */
public class UserServiceLoginUser implements ILoginUser {

    @Autowired
    private UserClient userClient;

    @Override
    public LoginUser getLoginUser(Long userId) {
        // 通过远程调用的方式 获取用户的信息
        User selectedUser = userClient.findById(userId);
        LoginUser loginUser = new LoginUser();
        loginUser.setId(userId);
        loginUser.setName(selectedUser.getUsername());
        return loginUser;
    }
}
